# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        潘炎珍  
# Name:         GetUrl
# Description:
# Author:       98745
# Date:         2019/4/6
#-------------------------------------------------------------------------------
import requests
from bs4 import *
from projects.douban_spider.GetInfo import *

def geturl(url):
    '''获取每本书的详细信息的网址'''
    try:
        headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'}
        # url='https://book.douban.com/tag/%E5%B0%8F%E8%AF%B4?start=160&type=T'
        response=requests.get(url,headers=headers)
        soup=BeautifulSoup(response.text,'lxml')
        url_list=[]
        soup_li=soup.find_all('li',{'class':'subject-item'})
        for item in soup_li:
            div=item.find('div',{'class':'info'})
            url_list.append(div.h2.a['href'])
        if len(url_list)>0:
            getinfo(url_list)
    except Exception as e:
        print(e)
    # return url_list



# if __name__=='__main__':
#     geturl()
# #     print(geturl())
